﻿namespace Sidvall.Data
{
    public class SortItem : ISortItem
    {
        #region Business Members

        public string FieldName { get; set; }
        public bool Ascending { get; set; }

        #region Copy

        public SortItem Copy()
        {
            var item = new SortItem()
            {
                Ascending = this.Ascending,
                FieldName = this.FieldName,
            };
            return item;
        }

        #endregion
        #region ToString

        public override string ToString()
        {
            return Sidvall.SystemContext.Current.SqlManager.GetSqlOrderBy(this, null);
        }

        #endregion

        #endregion
        #region Constructors

        public SortItem()
        {
        }
        public SortItem(string fieldName)
            : this(fieldName, true)
        {
        }
        public SortItem(string fieldName, bool ascending)
        {
            this.FieldName = fieldName;
            this.Ascending = ascending;
        }

        #endregion
    }
}
